package universityModel.curriculum;

import universityModel.lesson.LessonInterface;
import universityModel.utils.OutputControl;

/**
 *
 * @author Parkhomenko Dmytro
 */

/**
 * Describe a work 5 - days week 
 * One element from Day[] workwWeek is a one work day
 */
public class Curriculum  extends OutputControl implements Cloneable {
    private final int NUM_WEEKDAYS = 5;
    private String group;
    private Day[] weekDays = new Day[NUM_WEEKDAYS];
	
        /**
         * Constructor of Curriculum class
         * At first time I init work week using default cell 
         * info from class  CellInformation
         * @param group name  of group that destinat for curriculum
         */
    public Curriculum(String group) {
        this.group = group;
        initWeekDays();
    }

    public String getGroup(){
	return group;
    }
        
    @Override
    public Curriculum clone() {
        try {
            Curriculum curriculum = (Curriculum) super.clone();
            curriculum.group = group;
            curriculum.weekDays = weekDays.clone();
            return curriculum;
        } catch (CloneNotSupportedException e) {
            return null;
        }
    }
        
    public void addLesson(LessonInterface lesson) {
        int numOfDay = lesson.getWeekDay();
        weekDays[numOfDay].add(lesson);
    }

    private void initWeekDays() {
        for(WeekDays wd: WeekDays.values()) {
        	int num = wd.getDay();
                
        	if(num >= NUM_WEEKDAYS) {
        		break;
        	}
                
            weekDays[num] = new Day(wd);
        }
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        for(int numOfDay = 0; numOfDay < NUM_WEEKDAYS; numOfDay++) {
            sb.append(weekDays[numOfDay].getDay());
        }
        return sb.toString();
    }
}
